<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('码盘收货管理')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="gysmc" name="gysmc" placeholder="供应商名称"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">ASN编号</label>
                        <input type="text" class="layui-input" id="asnbh" name="asnbh" placeholder="ASN编号"/>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">PO编号</label>
                        <input type="text" class="layui-input" id="dycgdbh" name="dycgdbh" placeholder="关联PO编号"/>
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload">查询</a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-primary" style="background-color: #40AFFE">重置</button>
                    </div>
                    <div class="moreSearch" style="display: none">
                        <div class="layui-inline">
                            <label class="layui-form-label">创建时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="stime" id="stime"
                                       placeholder="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label"> </label>
                            <div class="layui-input-inline" style="height:20px">
                                --
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">&nbsp;</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="etime" name="etime"
                                       placeholder="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">ASN状态</label>
                            <select id="asnzt" name="asnzt" class="selector" lay-filter="aihao">
                                <option value="" ></option>
                                <option value="0">初始</option>
                                <option value="1" >部分收货</option>
                                <option value="2">完全收货</option>
                                <option value="3">订单取消</option>
                                <option value="4">订单完成</option>
                            </select>
                        </div>
                    </div>
                </form>
                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
                <div class="group-button" id="toolbar">

                  <!--
                     <a class="layui-btn layui-btn-sm layui-btn-normal edit-btn">
                         <i class="layui-icon">&#x1005;</i> 修改
                     </a>
                     <a class="layui-btn layui-btn-sm layui-btn-normal out-put">
                         <i class="layui-icon">&#x1005;</i> 导出
                     </a>-->
                    <!-- Single button -->
                    <!-- <div class="btn-group">
                         <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                 aria-haspopup="true" aria-expanded="false">
                             多选操作 <span class="caret"></span>
                         </button>
                         <ul class="dropdown-menu">
                             <li><a id="btn_jin" href="#">禁用</a></li>
                             <li><a id="btn_qi" href="#">启用</a></li>
                         </ul>
                     </div>-->
                </div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>

</body>


<div th:include="/public/public_js::public_js"></div>
<style type="text/css">
    .moreBtn {
        width: 50px;
        height: 20px;
        text-align: center;
        color: #fff;
        line-height: 20px;
        background-color: #eee;
        position: relative;
        margin: 0 auto;
        cursor: pointer;
    }

    .moreBtn:before {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(30deg);
        background: #eee;
        border-top-left-radius: 8px;
        left: -20px;
        top: 0;
    }

    .moreBtn:after {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(-30deg);
        background: #eee;
        border-top-right-radius: 8px;
        top: 0;
        right: -20px;
    }
</style>
<script>
    $(function () {
        $(".moreBtn").on("click", function () {
            $(".moreSearch").toggle();
        });
    });
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate'], function () {
        window.operateEvent = {
            "click #btn_qr": function (e, value, row, index) {//确认收货
                editDialog(row.id);
            },
            "click #btn_bf": function (e, value, row, index) {//部分收货
                bf_Dialog(row.id);
            },
            "click #btn_qx": function (e, value, row, index) {//取消收货
                startDialog(row.id);
            }
        }

        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;

        //确认收货
        function editDialog(id) {
                zzpUtils.dialog({
                    title: "确认收货",
                    type: 2,
                    content: "/mpsh/qrMpsh?id=" + id,
                    area: ['100%', '100%'], //设置dialog大小，也可以不设置，
                    end: function () {//修改成功后刷新
                        zzpUtils.refreshTable("#table");
                    }
                });
        }
        //部分收货
        function bf_Dialog(id) {
            zzpUtils.dialog({
                title: "部分收货",
                type: 2,
                content: "/mpsh/bfsh?id=" + id,
                area: ['100%', '100%'], //设置dialog大小，也可以不设置，
                end: function () {//修改成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }
        //取消收货
        function startDialog(id) {
            var ids = [];
            ids.push(id);
            zzpUtils.confirm("是否确定启用库区", function (index) {
                zzpUtils.action({
                    url: "/wmsreceiving/rollBackReceiving",
                    data: JSON.stringify({ids: ids}),
                    success: function (data) {
                        setTimeout(function () {
                            layer.msg(data.title);
                        }, 500);
                        zzpUtils.refreshTable("#table");
                    }, error: function (xhr, textStatus) {
                        console.log(textStatus);
                        console.log(xhr)
                    }
                })
            })
            return false;
        }

        laydate.render({
            elem: '#stime'
            , theme: '#20a0ff'
        })
        laydate.render({
            elem: '#etime'
            , theme: '#20a0ff'
        })
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination: true,
            url: '/wmsEstimatedArrivalOrder/seachSorting',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'ckmc',
                title: '仓库',
                width:130
            }, {
                field: 'hzmc',
                title: '货主',
                width:150
            }, {
                field: 'asnbh',
                title: 'ASN编号',
                width:120
            }, {
                field: 'show_asnlx',
                title: 'ASN类型',
                width:130
            }, {
                field: 'show_asnzt',
                title: 'ASN状态'
            }, {
                field: 'yxj',
                title: '优先级'
            }, {
                field: 'cjsj',
                title: '创建时间',
                width:130
            }, {
                field: 'show_shzt',
                title: '审核状态'
            }, {
                field: 'zdr',
                title: '制单人'
            }, {
                field: 'ddshr',
                title: '审核人'
            }, {
                field: 'show_dyzt',
                title: '打印状态'
            }, {
                field: 'gysmc',
                title: '供应商名称'
            }, {
                field: 'show_mpzt',
                title: '码盘状态'
            }, {
                field: 'caozuo',
                title: '操作',
                width:200,
                events: operateEvent,
                formatter: operateFormatter
            }],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }
        });

        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
            if (row.asnzt == 0) {//初始
                return [
                    '<a class="layui-btn layui-btn-xs" id="btn_qr">确认收货</a>'
                ].join('')
            } else if(row.asnzt==1) {//部分收货
                return [
                    '<a class="layui-btn layui-btn-xs" id="btn_bf">部分收货</a>',
                    '<a class="layui-btn layui-btn-danger layui-btn-xs" id="btn_qx">取消收货</a>'
                ].join('')
            }else if(row.asnzt==2){//完全收货
                return [
                    '<a class="layui-btn layui-btn-danger layui-btn-xs" id="btn_qx">取消收货</a>'
                ].join('')
            }
        }

        //查询
        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        })
    });


</script>
</html>